import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';
import 'package:xindong/routes/tab_home/controller/xindong_fujin_vm.dart';
import 'package:xindong/routes/tab_home/view/xindong_user_list_cell.dart';
import 'package:xindong/widgets/common/xindong_common_widget.dart';
import 'package:xindong/widgets/container/xindong_empty_container.dart';
import 'package:xindong/widgets/container/xindong_getx_builder_container.dart';
import 'package:xindong/widgets/container/xindong_keep_alive_container.dart';

class XinDongHomeNearbyListView extends StatelessWidget {
  const XinDongHomeNearbyListView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return XinDongKeepAliveContainer(
      keepAlive: true,
      child: XinDongGetBuilder<XinDongHomeNearbyVM>(builder: (viewClass) {
        return XinDongRefreshContainer(
          viewClass: viewClass,
          child: XinDongEmptyContainer(
            dataList: viewClass.dataList,
            emptyTips: "开启定位，才能匹配附近的人",
            child: ListView.separated(
              controller: viewClass.scrollController,
              itemCount: viewClass.dataList?.length ?? 0,
              itemBuilder: (BuildContext context, int index) {
                final model = viewClass.dataList![index];
                return XinDongUserListCell(model: model);
              },
              separatorBuilder: (BuildContext context, int index) {
                return const SizedBox();
              },
            ),
          ),
        );
      }),
    );
  }
}
